import urllib.request


def getHTML(url):
    html = urllib.request.urlopen(url).read()
    return html


def saveHTML(file_name, file_content):
    # 注意windows文件命名的禁用符，比如 /
    with open(file_name.replace('/', '_') + ".html", "wb") as f:
        # 写文件用bytes而不是str，所以要转码
        f.write(file_content)


aurl = "http://www.pxu.edu.cn/"

html = getHTML(aurl)
print("网页已爬取")

saveHTML("萍乡学院", html)
print("网页已存储至本地")
